import React from 'react';
import {Spin, Card, Button, Table, Row, Col, Divider, Collapse, Checkbox, Form} from 'antd';
import DescriptionList from 'ant-design-pro/lib/DescriptionList';
import PropTypes from 'prop-types';
import {currency, repairType, claimAthType, vehicleOperationsNature, faultType, fileType} from '../Enum';
import routes from './routes';
import {DATETIME_FORMAT, TABLE, DATE_FORMAT, FILES_API, FORM_OPTIONS, FORM_ROW_OPTIONS} from '../constants';
import {conventEnumValueToString, formatDateTime, formatAmount, formatPercent} from '../utils';
import {getDetail, getcClaimHistoriesList, countersignerPass, countersignerRefuse, countersigner} from './api';
import {injectIntl} from './intl';
import TextInput from 'Shared/components/TextInput';
import PersonnelSelectPanel from './PersonnelSelectPanel';
import styles from './style.css';
import ImageUpload from './PageAdd/ImageUpload';
import SearchInput from 'Shared/components/SearchInput';
import ClaimHistoryPanel from './PageAdd/ClaimHistoryPanel';
import {countersignerValidator} from './validator';
import Return from '../common/Return';
const {Description} = DescriptionList;
const {Panel} = Collapse;
const FormItem = Form.Item;
const date = new Date();
class CountersignerPanel extends React.PureComponent {
    state = {
        loading: false,
        hasOperat: false,
        isValidate: false,
        data: {},
        details: [],
        claimWorkItemDetails: [],
        claimAthDetails: [],
        claimMaterialDetails: [],
        claimHistories: {},
        showPersonnelSelectPanel: false,
    }
    componentDidMount() {
        this.getDetailInfo();
    }
    
    getDetailInfo = () => {
        const id = this.props.id;
        this.setState({loading: true});
        getDetail(id)
            .then(res => {
                if(res.ok) {
                    this.setState({
                        loading: false,
                        data: res.data,
                        details: res.data.details,
                        claimWorkItemDetails: res.data.claimWorkItemDetails,
                        claimAthDetails: res.data.claimAthDetails,
                        claimMaterialDetails: res.data.claimMaterialDetails,
                        claimApplyCountersignResults: res.data.claimApplyCountersignResults,
                    });
                    this.getClaimHistories(res.data.vin, res.data.createTime);
                } else
                    this.setState(({
                        loading: false
                    }));
            });
    }
    
    getClaimHistories = (vin, createTime) => {
        this.setState({
            loading: true
        });
        getcClaimHistoriesList({
            vin,
            createTime
        })
            .then(res => {
                if(res.ok)
                    this.setState({
                        loading: false,
                        claimHistories: res.data
                    });
                else
                    this.setState(({
                        loading: false
                    }));
            });
    }
    onClickSearchHistoryBtn = () => {
        window.open(
            `#dcs/afterSales/claimHistory/applyHistory?vin=${this.state.data.vin}`
        );
    };
    onPass = () => {
        const data = this.state.data;
        const condition = {
            countersignedComment: data.countersignedComment || 'Agree',
            rowVersion: data.rowVersion,
        };
        this.setState({
            loading: true,
            data: Object.assign({}, this.state.data, {
                countersignedComment: 'Agree'
            })
        });
        countersignerPass(this.props.id, condition).then(res => {
            if(res.ok)
                this.props.successReturn();
            if(!this.isunmount)
                this.setState({loading: false});
        });
    }
    onRefuse = () => {
        const data = this.state.data;
        const condition = {
            countersignedComment: data.countersignedComment || 'Reject',
            rowVersion: data.rowVersion,
        };
        this.setState({
            loading: true,
            data: Object.assign({}, this.state.data, {
                countersignedComment: 'Reject'
            })
        });
        countersignerRefuse(this.props.id, condition).then(res => {
            if(res.ok)
                this.props.successReturn();
            if(!this.isunmount)
                this.setState({loading: false});
        });
    }
    onCountersigner = () => {
        const data = this.state.data;
        const isValid = countersignerValidator(data);
        if(!isValid) {
            this.setState({
                isValidate: true
            });
            return;
        }
        this.setState({
            data: Object.assign({}, this.state.data, {
                countersignedComment: 'Agree'
            })
        });
        const condition = {
            countersigner: data.countersigner,
            rowVersion: data.rowVersion,
        };
        this.setState({loading: true});
        countersigner(this.props.id, condition).then(res => {
            if(res.ok)
                this.props.successReturn();
            if(!this.isunmount)
                this.setState({loading: false});
        });
    }
    onClickOkOnPopconfirm = () => {
        this.props.onCancel();
    }
    onChange = (value, name) => {
        const data = Object.assign({}, this.state.data, {
            [name]: value
        });
        this.setState({
            data,
            hasOperat: true
        });
    }
    onClickSearchPersonnelBtn = () => {
        this.setState({
            showPersonnelSelectPanel: true
        });
    }
    onClosePersonnelSelectPanel = () => {
        this.setState({showPersonnelSelectPanel: false});
    }
    
    onSelectPersonnel = records => {
        this.setState({
            data: Object.assign({}, this.state.data, {
                countersigner: records.id,
                countersignerName: records.name,
            }),
            hasOperat: true,
            showPersonnelSelectPanel: false
        });
    }
    render() {
        const {data, details, claimWorkItemDetails, claimMaterialDetails, claimAthDetails, claimHistories, isValidate, loading, claimApplyCountersignResults} = this.state;
        const {formatMessage} = this.props.intl;
        
        const claimAthDetailTuPhoto = claimAthDetails.find(v => v.type === claimAthType.图片资料 && v.fileType === fileType.图片) || {};
        const claimAthDetailTuFile = claimAthDetails.find(v => v.type === claimAthType.图片资料 && v.fileType === fileType.文件) || {};
        const claimAthDetailFaPhoto = claimAthDetails.find(v => v.type === claimAthType.发票扫描图片 && v.fileType === fileType.图片) || {};
        const claimAthDetailFaFile = claimAthDetails.find(v => v.type === claimAthType.发票扫描图片 && v.fileType === fileType.文件) || {};
        const columnMaterials = [
            {
                title: formatMessage({
                    id: 'countersignerPanel.materialTablePanel.usedPartCode',
                    defaultMessage: '旧件编号'
                }),
                dataIndex: 'usedPartCode'
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.materialTablePanel.usedPartName',
                    defaultMessage: '旧件名称'
                }),
                dataIndex: 'usedPartName'
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.materialTablePanel.isCaused',
                    defaultMessage: '是否主损件'
                }),
                dataIndex: 'isCaused',
                render: text => text ? formatMessage({
                    id: 'countersignerPanel.materialTablePanel.isCausedYes',
                    defaultMessage: '是'
                }) : formatMessage({
                    id: 'countersignerPanel.materialTablePanel.isCausedNo',
                    defaultMessage: '否'
                })
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.materialTablePanel.unit',
                    defaultMessage: '计量单位'
                }),
                dataIndex: 'unit'
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.materialTablePanel.quantity',
                    defaultMessage: '数量'
                }),
                dataIndex: 'quantity'
            }
        ];
        if(!this.props.isMoneyVisible)
            columnMaterials.splice(5, 0,
                {
                    title: formatMessage({
                        id: 'countersignerPanel.materialTablePanel.price',
                        defaultMessage: '单价'
                    }),
                    dataIndex: 'price',
                    render: text => formatAmount(text)
                },
                {
                    title: formatMessage({
                        id: 'countersignerPanel.materialTablePanel.mgmtRate',
                        defaultMessage: '管理费率'
                    }),
                    dataIndex: 'mgmtRate',
                    render: text => formatPercent(text)
                },
                {
                    title: formatMessage({
                        id: 'countersignerPanel.materialTablePanel.mgmtFee',
                        defaultMessage: '管理费'
                    }),
                    dataIndex: 'mgmtFee',
                    render: text => formatAmount(text)
                },
                {
                    title: formatMessage({
                        id: 'countersignerPanel.materialTablePanel.materialFee',
                        defaultMessage: '材料费合计'
                    }),
                    dataIndex: 'materialFee',
                    render: text => formatAmount(text)
                });
        const columnWorkItems = [
            {
                title: formatMessage({
                    id: 'countersignerPanel.workItemDetailPanel.workItemCode',
                    defaultMessage: '维修项目编号'
                }),
                dataIndex: 'workItemCode'
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.workItemDetailPanel.workItemName',
                    defaultMessage: '维修项目名称'
                }),
                dataIndex: 'workItemName'
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.workItemDetailPanel.laborHour',
                    defaultMessage: '工时'
                }),
                dataIndex: 'laborHour'
            },
            {
                title: formatMessage({
                    id: 'countersignerPanel.workItemDetailPanel.remark',
                    defaultMessage: '备注'
                }),
                dataIndex: 'remark'
            }
        ];
        if(!this.props.isMoneyVisible)
            columnMaterials.splice(3, 0,
                {
                    title: formatMessage({
                        id: 'countersignerPanel.workItemDetailPanel.laborPrice',
                        defaultMessage: '工时单价'
                    }),
                    dataIndex: 'laborPrice',
                    render: text => formatAmount(text)
                },
                {
                    title: formatMessage({
                        id: 'countersignerPanel.workItemDetailPanel.laborFee',
                        defaultMessage: '工时费'
                    }),
                    dataIndex: 'laborFee',
                    render: text => formatAmount(text)
                });
        const colums = [{
            title: formatMessage({
                id: 'countersignerPanel.usedPartCode',
                defaultMessage: '旧件编号'
            }),
            dataIndex: 'usedPartCode'
        },
        {
            title: formatMessage({
                id: 'countersignerPanel.usedPartName',
                defaultMessage: '旧件名称'
            }),
            dataIndex: 'usedPartName'
        },
        {
            title: formatMessage({
                id: 'countersignerPanel.unit',
                defaultMessage: '计量单位'
            }),
            dataIndex: 'unit'
        },
        {
            title: formatMessage({
                id: 'countersignerPanel.quantity',
                defaultMessage: '计价数量'
            }),
            dataIndex: 'quantity'
        }];
        if(!this.props.isMoneyVisible)
            columnMaterials.splice(4, 0,
                {
                    title: formatMessage({
                        id: 'countersignerPanel.price',
                        defaultMessage: '单价'
                    }),
                    dataIndex: 'price',
                    render: text => formatAmount(text)
                },
                {
                    title: formatMessage({
                        id: 'countersignerPanel.materialFee',
                        defaultMessage: '材料费合计'
                    }),
                    dataIndex: 'materialFee',
                    render: text => formatAmount(text)
                });
        const columCountersigns = [{
            title: formatMessage({
                id: 'detailPanel.countersignerName',
                defaultMessage: '会签人姓名'
            }),
            dataIndex: 'countersignerName'
        },
        {
            title: formatMessage({
                id: 'detailPanel.countersignedComment',
                defaultMessage: '会签意见'
            }),
            dataIndex: 'countersignedComment'
        },
        {
            title: formatMessage({
                id: 'detailPanel.countersignedResult',
                defaultMessage: '会签结果'
            }),
            dataIndex: 'countersignedResult'
        },
        {
            title: formatMessage({
                id: 'detailPanel.countersignedTime',
                defaultMessage: '会签时间'
            }),
            dataIndex: 'countersignedTime',
            render: text => formatDateTime(text, DATETIME_FORMAT)
        }];
        return (
            <div className="form-standard">
                <Spin spinning={this.state.loading}>
                    <Card title={<Row><Col span={6}>{
                        formatMessage({
                            id: 'countersignerPanel.card.claimInfo',
                            defaultMessage: '基础信息'
                        })
                    }</Col></Row>}>
                        <DescriptionList>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.code',
                                defaultMessage: '预授权单号'
                            })}>{data.code}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.brandCode',
                                defaultMessage: '品牌'
                            })}>{data.brandCode}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.isOtherArea',
                                defaultMessage: '是否跨区域索赔'
                            })}>
                                {data.isOtherArea ? 'Yes' : 'No'}
                            </Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.vin',
                                defaultMessage: 'VIN'
                            })}>{data.vin}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.repairType',
                                defaultMessage: '索赔类型'
                            })}>{conventEnumValueToString(repairType, data.repairType)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.subClaimApplyCode',
                                defaultMessage: '经销商预授权单号'
                            })}>{data.subClaimApplyCode}
                            </Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.supplierCode',
                                defaultMessage: '供应商编号'
                            })}>{data.supplierCode}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.supplierName',
                                defaultMessage: '供应商名称'
                            })}>{data.supplierName}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.salesDealerCode',
                                defaultMessage: '经销商编号'
                            })}>{data.subDealerCode}</Description>
                            {
                                data.repairType === repairType.备件索赔 &&
                                <Description term={formatMessage({
                                    id: 'countersignerPanel.operation.partPurchasedDate',
                                    defaultMessage: '自费购件时间'
                                })}>{formatDateTime(data.partPurchasedDate, DATE_FORMAT)}</Description>
                            }
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.repairCode',
                                defaultMessage: '维修单号'
                            })}>{data.repairCode}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.shipmentPort',
                                defaultMessage: '维修日期'
                            })}>{formatDateTime(data.repairDate, DATE_FORMAT)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.faultType',
                                defaultMessage: '故障类型'
                            })}>{conventEnumValueToString(faultType, data.faultType)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.faultItem',
                                defaultMessage: '故障代码'
                            })}><span className="value-font">({data.faultItemCode}) {data.faultItemName}</span></Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.faultMode',
                                defaultMessage: '故障模式'
                            })}><span className="value-font">({data.faultModeCode}) {data.faultModeName}</span></Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.artisan',
                                defaultMessage: '技术分析员'
                            })}>{data.artisan}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.checkDate',
                                defaultMessage: '检查日期'
                            })}>{formatDateTime(data.checkDate, DATE_FORMAT)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.createName',
                                defaultMessage: '填报人'
                            })}>{data.creatorName}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.createTime',
                                defaultMessage: '申请日期'
                            })}>{formatDateTime(data.createTime, DATE_FORMAT)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.faultDescription',
                                defaultMessage: '故障描述'
                            })}>{data.faultDescription}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.checkResul',
                                defaultMessage: '检查分析结果'
                            })}>{data.checkResult}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.artisanResult',
                                defaultMessage: '技术判断意见'
                            })}>{data.artisanResult}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.dealerApproveComment',
                                defaultMessage: '总代理商处理意见'
                            })}>{data.dealerApproveComment}</Description>
                        </DescriptionList>
                    </Card>
                    <Card title={formatMessage({
                        id: 'countersignerPanel.card.vehicleInfo',
                        defaultMessage: '车辆信息'
                    })}>
                        <DescriptionList>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.wholesaleDealerCode',
                                defaultMessage: '总代'
                            })}>{`(${data.wholesaleDealerCode})${data.wholesaleDealerName}`}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.country',
                                defaultMessage: '国家'
                            })}>{data.country}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.currency',
                                defaultMessage: '币种'
                            })}>{conventEnumValueToString(currency, data.currency)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.mileage',
                                defaultMessage: '行驶里程'
                            })}>{data.mileage}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.engineCode',
                                defaultMessage: '发动机号'
                            })}>{data.engineCode}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.transmissionSn',
                                defaultMessage: '变速箱号'
                            })}>{data.transmissionSn}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.productCategoryCode',
                                defaultMessage: '车型编号'
                            })}>{data.productCategoryCode}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.productCategoryName',
                                defaultMessage: '车型名称'
                            })}>{data.productCategoryName}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.annoucementNumber',
                                defaultMessage: '公告号'
                            })}>{data.annoucementNumber}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.operationsNature',
                                defaultMessage: '客户性质'
                            })}>{conventEnumValueToString(vehicleOperationsNature, data.operationsNature)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.isKD',
                                defaultMessage: 'CBU/KD索赔'
                            })}>{data.isKD === true && formatMessage({
                                    id: 'countersignerPanel.operation.kd',
                                    defaultMessage: 'KD'
                                })}
                                {data.isKD === false && formatMessage({
                                    id: 'countersignerPanel.operation.cbu',
                                    defaultMessage: 'CBU'
                                })}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.saleDate',
                                defaultMessage: '实销日期'
                            })}>{formatDateTime(data.saleDate, DATE_FORMAT)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.shipDate',
                                defaultMessage: '发车日期'
                            })}>{formatDateTime(data.shipDate, DATE_FORMAT)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.productionDate',
                                defaultMessage: '生产日期'
                            })}>{formatDateTime(data.productionDate, DATE_FORMAT)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.customerName',
                                defaultMessage: '用户姓名'
                            })}>{data.customerName}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.cellPhoneNumber',
                                defaultMessage: '用户电话'
                            })}>{data.cellPhoneNumber}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.companyName',
                                defaultMessage: '用户公司'
                            })}>{data.companyName}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.address',
                                defaultMessage: '用户地址'
                            })}>{data.address}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.email',
                                defaultMessage: '用户Email'
                            })}>{data.email}</Description>
                        </DescriptionList>
                    </Card>
                    <Collapse defaultActiveKey={['1', '2', '3', '4', '5', '6']}>
                        <Panel header={formatMessage({
                            id: 'countersignerPanel.table.claimMaterialDetails',
                            defaultMessage: '材料清单'
                        })} key="1">
                            <Table
                                className="white-space-nowrap"
                                columns={columnMaterials}
                                rowKey="usedPartId"
                                pagination={false}
                                dataSource={claimMaterialDetails}
                                {...TABLE} />
                        </Panel>
                        <Panel header={formatMessage({
                            id: 'newPanel.operation.attachment',
                            defaultMessage: '附件清单'
                        })} key="6">
                            {claimAthDetails && claimAthDetails.length > 0
                                ? <div>
                                    {
                                        (claimAthDetailTuPhoto || claimAthDetailTuFile) &&
                                        <DescriptionList title={formatMessage({
                                            id: 'approvePanel.card.attachmentTu',
                                            defaultMessage: '图片资料附件'
                                        })} size="large">
                                            {(claimAthDetailTuPhoto.attachments && claimAthDetailTuPhoto.attachments.length > 0) &&
                                            <div><ImageUpload fileList={claimAthDetailTuPhoto.attachments} isUpload={false}/>
                                                <Divider /></div>}
                                            {(claimAthDetailTuFile.attachments && claimAthDetailTuFile.attachments.length > 0) &&
                                                claimAthDetailTuFile.attachments.map(item => (<Description key={item.fileId}>
                                                    <a icon="download" download
                                                        href={`${FILES_API.files}/${item.fileId}`} size="small">{item.fileName}</a></Description>))}
                                        </DescriptionList>
                                    }
                                    <Divider className={styles.divider}/>
                                    {
                                        data.repairType === repairType.备件索赔 && (claimAthDetailFaPhoto || claimAthDetailFaFile) &&
                                        <DescriptionList title={formatMessage({
                                            id: 'approvePanel.card.attachmentFa',
                                            defaultMessage: '发票扫描图片附件'
                                        })} size="large">
                                            {(claimAthDetailFaPhoto.attachments && claimAthDetailFaPhoto.attachments.length > 0) &&
                                            <div><ImageUpload fileList={claimAthDetailTuPhoto.attachments} isUpload={false}/>
                                                <Divider /></div>}
                                            {(claimAthDetailFaFile.attachments && claimAthDetailFaFile.attachments.length > 0) &&
                                                claimAthDetailFaFile.attachments.map(item => (<Description key={item.fileId}>
                                                    <a icon="download" download
                                                        href={`${FILES_API.files}/${item.fileId}`} size="small">{item.fileName}</a></Description>))}
                                        </DescriptionList>
                                    }
                                </div>
                                : formatMessage({
                                    id: 'countersignerPanel.content.noAttachment',
                                    defaultMessage: '暂无附件'
                                })}
                        </Panel>
                        <Panel header={formatMessage({
                            id: 'countersignerPanel.table.claimWorkItemDetails',
                            defaultMessage: '项目清单'
                        })} key="2">
                            <Table
                                className="white-space-nowrap"
                                columns={columnWorkItems}
                                rowKey="workItemId"
                                pagination={false}
                                dataSource={claimWorkItemDetails}
                                {...TABLE} />
                        </Panel>
                        <Panel header={formatMessage({
                            id: 'countersignerPanel.table.details',
                            defaultMessage: '辅料清单'
                        })} key="3">
                            <Table
                                className="white-space-nowrap"
                                columns={colums}
                                rowKey="usedPartId"
                                pagination={false}
                                dataSource={details}
                                {...TABLE} />
                        </Panel>
                        {!data.isOtherArea && <Panel header={formatMessage({
                            id: 'newPanel.operation.claimHistory',
                            defaultMessage: '历史索赔信息'
                        })} key="4">
                            <ClaimHistoryPanel data={claimHistories} />
                        </Panel>}
                        <Panel header={formatMessage({
                            id: 'newPanel.operation.claimApplyCountersignResults',
                            defaultMessage: '历史会签信息'
                        })} key="5">
                            <Table
                                className="white-space-nowrap"
                                columns={columCountersigns}
                                rowKey="id"
                                pagination={false}
                                dataSource={claimApplyCountersignResults}
                                {...TABLE} />
                        </Panel>
                    </Collapse>
                    {!this.props.isMoneyVisible &&
                    <Card title={formatMessage({
                        id: 'countersignerPanel.card.feeInfo',
                        defaultMessage: '索赔费用'
                    })}>
                        <DescriptionList>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.laborFee',
                                defaultMessage: '工时费'
                            })}>{formatAmount(data.laborFee)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.materialFee',
                                defaultMessage: '材料费'
                            })}>{formatAmount(data.materialFee)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.assiantFee',
                                defaultMessage: '辅料费'
                            })}>{formatAmount(data.assiantFee)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.mgmtFeeRate',
                                defaultMessage: '管理费率'
                            })}>{formatPercent(data.mgmtFeeRate)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.mgmtFee',
                                defaultMessage: '管理费'
                            })}>{formatAmount(data.mgmtFee)}</Description>
                            <Description term={formatMessage({
                                id: 'countersignerPanel.operation.totalFee',
                                defaultMessage: '费用合计'
                            })}>{formatAmount(data.totalFee)}</Description>
                        </DescriptionList>
                    </Card>}
                    <Card
                        title={formatMessage({
                            id: 'countersignerPanel.operation.countersigner',
                            defaultMessage: '会签区域'
                        })}>
                        <Form>
                            <Row>
                                <Col {...FORM_ROW_OPTIONS.col}>
                                    <FormItem
                                        label={this.props.intl.formatMessage({
                                            id: 'countersignerPanel.operation.countersignedComment',
                                            defaultMessage: '会签意见'
                                        })}{...FORM_ROW_OPTIONS.item} validateStatus={isValidate && !data.countersignedComment ? 'error' : null} required>
                                        <TextInput
                                            name="countersignedComment"
                                            type="textarea"
                                            value={data.countersignedComment}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem
                                        label={formatMessage({
                                            id: 'countersignerPanel.form.countersigner',
                                            defaultMessage: '会签人'
                                        })}{...FORM_OPTIONS.item}>
                                        <SearchInput
                                            disabled={true}
                                            value={data.countersignerName}
                                            onClickSearchBtn={() => this.onClickSearchPersonnelBtn()} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem
                                        label={formatMessage({
                                            id: 'countersignerPanel.form.date',
                                            defaultMessage: '会签时间'
                                        })}
                                        {...FORM_OPTIONS.item}>
                                        {formatDateTime(date, DATETIME_FORMAT)}
                                    </FormItem>
                                </Col>
                            </Row>
                        </Form>
                    </Card>
                    <Card className={styles.optionBtn}>
                        <Button
                            onClick={this.onCountersigner}
                            loading={loading}>
                            {formatMessage({
                                id: 'countersignerPanel.operation.onCountersigner',
                                defaultMessage: '下一级会签'
                            })}
                        </Button>
                        <Button
                            onClick={this.onRefuse}
                            loading={loading}>
                            {formatMessage({
                                id: 'countersignerPanel.operation.onRefuse',
                                defaultMessage: '拒绝会签'
                            })}
                        </Button>
                        <Button
                            type="primary"
                            onClick={this.onPass}
                            loading={loading}>
                            {formatMessage({
                                id: 'countersignerPanel.operation.onPass',
                                defaultMessage: '会签通过'
                            })}
                        </Button>
                    </Card>
                </Spin>
                {
                    this.state.showPersonnelSelectPanel &&
                    <PersonnelSelectPanel
                        selectKey={data.countersigner}
                        onCancel={this.onClosePersonnelSelectPanel}
                        onSelect={this.onSelectPersonnel} />
                }
                <div className="page-toolbar">
                    <Return
                        disabled={this.state.loading}
                        onConfirm={this.onClickOkOnPopconfirm}
                        showWarning={this.state.hasOperat} />
                </div>
            </div>
        );
    }
}

CountersignerPanel.propTypes = {
    history: PropTypes.object,
    id: PropTypes.string,
    intl: PropTypes.object,
    isMoneyVisible: PropTypes.bool
};

import {connect} from 'react-redux';
import {tableSearch} from './actions';
const mapStateToProps = (state, props) => ({
    isMoneyVisible: state.getIn((['page', 'domainData', 'initData', 'isMoneyVisible']))
});
const mapDispatchToProps = (dispatch, props) => ({
    successReturn: () => {
        dispatch(tableSearch());
        props.history.push(routes.query.url());
    },
    onCancel: () => {
        props.history.push(routes.query.url());
    },
});
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CountersignerPanel));
